// $ANTLR 3.3 Nov 30, 2010 12:45:30 C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g 2013-06-16 06:11:15

package output;

import java.util.Map;
import java.util.HashMap;
import runtime.*;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

public class PascalTo3addrParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "ID", "INT", "FLOAT", "CHAR", "EXPONENT", "WS", "ESC_SEQ", "HEX_DIGIT", "UNICODE_ESC", "OCTAL_ESC", "'program'", "';'", "'.'", "','", "'var'", "':'", "'integer'", "'boolean'", "'real'", "'char'", "'array'", "'['", "']'", "'of'", "'..'", "'true'", "'false'", "'begin'", "'end'", "'break'", "'continue'", "'repeat'", "'until'", "':='", "'if'", "'then'", "'else'", "'while'", "'do'", "'for'", "'to'", "'downto'", "'read'", "'('", "')'", "'readln'", "'write'", "'writeln'", "'not'", "'+'", "'-'", "'*'", "'/'", "'div'", "'mod'", "'and'", "'or'", "'='", "'<>'", "'<'", "'>'", "'<='", "'>='", "'procedure'", "'function'"
    };
    public static final int EOF=-1;
    public static final int T__14=14;
    public static final int T__15=15;
    public static final int T__16=16;
    public static final int T__17=17;
    public static final int T__18=18;
    public static final int T__19=19;
    public static final int T__20=20;
    public static final int T__21=21;
    public static final int T__22=22;
    public static final int T__23=23;
    public static final int T__24=24;
    public static final int T__25=25;
    public static final int T__26=26;
    public static final int T__27=27;
    public static final int T__28=28;
    public static final int T__29=29;
    public static final int T__30=30;
    public static final int T__31=31;
    public static final int T__32=32;
    public static final int T__33=33;
    public static final int T__34=34;
    public static final int T__35=35;
    public static final int T__36=36;
    public static final int T__37=37;
    public static final int T__38=38;
    public static final int T__39=39;
    public static final int T__40=40;
    public static final int T__41=41;
    public static final int T__42=42;
    public static final int T__43=43;
    public static final int T__44=44;
    public static final int T__45=45;
    public static final int T__46=46;
    public static final int T__47=47;
    public static final int T__48=48;
    public static final int T__49=49;
    public static final int T__50=50;
    public static final int T__51=51;
    public static final int T__52=52;
    public static final int T__53=53;
    public static final int T__54=54;
    public static final int T__55=55;
    public static final int T__56=56;
    public static final int T__57=57;
    public static final int T__58=58;
    public static final int T__59=59;
    public static final int T__60=60;
    public static final int T__61=61;
    public static final int T__62=62;
    public static final int T__63=63;
    public static final int T__64=64;
    public static final int T__65=65;
    public static final int T__66=66;
    public static final int T__67=67;
    public static final int T__68=68;
    public static final int ID=4;
    public static final int INT=5;
    public static final int FLOAT=6;
    public static final int CHAR=7;
    public static final int EXPONENT=8;
    public static final int WS=9;
    public static final int ESC_SEQ=10;
    public static final int HEX_DIGIT=11;
    public static final int UNICODE_ESC=12;
    public static final int OCTAL_ESC=13;

    // delegates
    // delegators


        public PascalTo3addrParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public PascalTo3addrParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        

    public String[] getTokenNames() { return PascalTo3addrParser.tokenNames; }
    public String getGrammarFileName() { return "C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g"; }



    	List<Map<String, Type>> types = new ArrayList<Map<String, Type>>();
    	List<Map<String, Integer>> ids = new ArrayList<Map<String, Integer>>();
    	List<Integer> idCount = new ArrayList<Integer>();	
    	
    	protected void pushScope() {
    		types.add(new HashMap<String, Type>());
    		ids.add(new HashMap<String, Integer>());
    		idCount.add(0);
    	}
    	protected void popScope() {
    		types.remove(types.size() - 1);
    		ids.remove(ids.size() - 1);
    		idCount.remove(idCount.size() - 1);
    	}
    	protected int allocateTempVariable(Type type) {
    		int rv = idCount.get(idCount.size() - 1);
    		idCount.set(idCount.size() - 1, rv + 1);
    		code.add(type + " V" + rv); 
    		return rv;
    	}
    	protected void declare(String name, Type type) {
    		Map<String, Type> last = types.get(types.size() - 1);
    		if (last.containsKey(name)) {
    			throw new CompilationError("Variable '" + name + "' is already declared in this scope");
    		}
    		last.put(name, type);
    		int id = idCount.get(idCount.size() - 1) + 1;
    		idCount.set(idCount.size() - 1, id);
    		ids.get(ids.size() - 1).put(name, id);
    		code.add(type.platformName() + " V" + id);
    	}
    	protected Type resolveType(String name) {
    		int curr = types.size() - 1;
    		while (curr >= 0) {
    			if (types.get(curr).containsKey(name)) {
    				return types.get(curr).get(name);
    			}
    		}
    		throw new CompilationError("Name '" + name + "' is not found");
    	}
    	protected int resolveID(String name) {
    		int curr = types.size() - 1;
    		while (curr >= 0) {
    			if (ids.get(curr).containsKey(name)) {
    				return ids.get(curr).get(name);
    			}
    		}
    		throw new CompilationError("Name '" + name + "' is not found");
    	}
    	protected final List<String> code = new ArrayList<String>();
    	
    	protected int labelCount = 0;
    	protected String newLabel() {
    		String rv = "l" + labelCount++;
    		code.add(rv + ":");
    		return rv;
    	}



    // $ANTLR start "parse"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:72:1: parse returns [List<String> result] : module ;
    public final List<String> parse() throws RecognitionException {
        List<String> result = null;

        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:72:37: ( module )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:72:39: module
            {
             code.clear(); 
            pushFollow(FOLLOW_module_in_parse28);
            module();

            state._fsp--;

             result = new ArrayList<String>(code); code.clear(); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return result;
    }
    // $ANTLR end "parse"


    // $ANTLR start "module"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:74:1: module : 'program' ID ';' block '.' ;
    public final void module() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:74:8: ( 'program' ID ';' block '.' )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:74:10: 'program' ID ';' block '.'
            {
            match(input,14,FOLLOW_14_in_module39); 
            match(input,ID,FOLLOW_ID_in_module41); 
            match(input,15,FOLLOW_15_in_module43); 
            pushFollow(FOLLOW_block_in_module45);
            block();

            state._fsp--;

            match(input,16,FOLLOW_16_in_module47); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "module"

    public static class number_return extends ParserRuleReturnScope {
        public String text;
        public Type type;
    };

    // $ANTLR start "number"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:76:1: number returns [String text, Type type] : ( INT | FLOAT );
    public final PascalTo3addrParser.number_return number() throws RecognitionException {
        PascalTo3addrParser.number_return retval = new PascalTo3addrParser.number_return();
        retval.start = input.LT(1);

        Token INT1=null;
        Token FLOAT2=null;

        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:77:2: ( INT | FLOAT )
            int alt1=2;
            int LA1_0 = input.LA(1);

            if ( (LA1_0==INT) ) {
                alt1=1;
            }
            else if ( (LA1_0==FLOAT) ) {
                alt1=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 1, 0, input);

                throw nvae;
            }
            switch (alt1) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:77:4: INT
                    {
                    INT1=(Token)match(input,INT,FOLLOW_INT_in_number62); 
                    retval.text = (INT1!=null?INT1.getText():null);   retval.type = IntType.instance; 

                    }
                    break;
                case 2 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:78:4: FLOAT
                    {
                    FLOAT2=(Token)match(input,FLOAT,FOLLOW_FLOAT_in_number72); 
                    retval.text = (FLOAT2!=null?FLOAT2.getText():null); retval.type = RealType.instance; 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "number"


    // $ANTLR start "idList"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:81:1: idList returns [List<String> list] : a= ID ( ',' b= ID )* ;
    public final List<String> idList() throws RecognitionException {
        List<String> list = null;

        Token a=null;
        Token b=null;

        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:82:2: (a= ID ( ',' b= ID )* )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:82:4: a= ID ( ',' b= ID )*
            {
             list = new ArrayList<String>(); 
            a=(Token)match(input,ID,FOLLOW_ID_in_idList93); 
             list.add((a!=null?a.getText():null)); 
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:82:69: ( ',' b= ID )*
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( (LA2_0==17) ) {
                    alt2=1;
                }


                switch (alt2) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:82:70: ',' b= ID
            	    {
            	    match(input,17,FOLLOW_17_in_idList98); 
            	    b=(Token)match(input,ID,FOLLOW_ID_in_idList102); 
            	     list.add((b!=null?b.getText():null)); 

            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return list;
    }
    // $ANTLR end "idList"


    // $ANTLR start "block"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:84:1: block returns [String label] : declarations statementSequence ;
    public final String block() throws RecognitionException {
        String label = null;

        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:85:2: ( declarations statementSequence )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:85:4: declarations statementSequence
            {
             
            		label = newLabel();
            		pushScope(); 
            	  
            pushFollow(FOLLOW_declarations_in_block124);
            declarations();

            state._fsp--;

            pushFollow(FOLLOW_statementSequence_in_block126);
            statementSequence();

            state._fsp--;

             
            	  	popScope(); 
            	  

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return label;
    }
    // $ANTLR end "block"


    // $ANTLR start "declarations"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:93:1: declarations : ( variableDeclBlock )? subprogDeclList ;
    public final void declarations() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:93:14: ( ( variableDeclBlock )? subprogDeclList )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:93:16: ( variableDeclBlock )? subprogDeclList
            {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:93:16: ( variableDeclBlock )?
            int alt3=2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==18) ) {
                alt3=1;
            }
            switch (alt3) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:93:17: variableDeclBlock
                    {
                    pushFollow(FOLLOW_variableDeclBlock_in_declarations140);
                    variableDeclBlock();

                    state._fsp--;


                    }
                    break;

            }

            pushFollow(FOLLOW_subprogDeclList_in_declarations144);
            subprogDeclList();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "declarations"


    // $ANTLR start "variableDeclBlock"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:95:1: variableDeclBlock : 'var' variableDecl ';' ( variableDecl ';' )* ;
    public final void variableDeclBlock() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:95:19: ( 'var' variableDecl ';' ( variableDecl ';' )* )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:95:21: 'var' variableDecl ';' ( variableDecl ';' )*
            {
            match(input,18,FOLLOW_18_in_variableDeclBlock153); 
            pushFollow(FOLLOW_variableDecl_in_variableDeclBlock155);
            variableDecl();

            state._fsp--;

            match(input,15,FOLLOW_15_in_variableDeclBlock157); 
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:95:44: ( variableDecl ';' )*
            loop4:
            do {
                int alt4=2;
                int LA4_0 = input.LA(1);

                if ( (LA4_0==ID) ) {
                    alt4=1;
                }


                switch (alt4) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:95:45: variableDecl ';'
            	    {
            	    pushFollow(FOLLOW_variableDecl_in_variableDeclBlock160);
            	    variableDecl();

            	    state._fsp--;

            	    match(input,15,FOLLOW_15_in_variableDeclBlock162); 

            	    }
            	    break;

            	default :
            	    break loop4;
                }
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "variableDeclBlock"


    // $ANTLR start "variableDecl"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:97:1: variableDecl : idList ':' type ;
    public final void variableDecl() throws RecognitionException {
        List<String> idList3 = null;

        Type type4 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:98:2: ( idList ':' type )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:98:4: idList ':' type
            {
            pushFollow(FOLLOW_idList_in_variableDecl175);
            idList3=idList();

            state._fsp--;

            match(input,19,FOLLOW_19_in_variableDecl177); 
            pushFollow(FOLLOW_type_in_variableDecl179);
            type4=type();

            state._fsp--;

             
            		for (String id : idList3) {
            			declare(id, type4);
            		}
            	  

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "variableDecl"


    // $ANTLR start "type"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:104:1: type returns [Type result] : ( 'integer' | 'boolean' | 'real' | 'char' | arrayType );
    public final Type type() throws RecognitionException {
        Type result = null;

        Type arrayType5 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:105:2: ( 'integer' | 'boolean' | 'real' | 'char' | arrayType )
            int alt5=5;
            switch ( input.LA(1) ) {
            case 20:
                {
                alt5=1;
                }
                break;
            case 21:
                {
                alt5=2;
                }
                break;
            case 22:
                {
                alt5=3;
                }
                break;
            case 23:
                {
                alt5=4;
                }
                break;
            case 24:
                {
                alt5=5;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 5, 0, input);

                throw nvae;
            }

            switch (alt5) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:105:4: 'integer'
                    {
                    match(input,20,FOLLOW_20_in_type196); 
                     result = IntType.instance; 

                    }
                    break;
                case 2 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:106:4: 'boolean'
                    {
                    match(input,21,FOLLOW_21_in_type203); 
                     result = BooleanType.instance; 

                    }
                    break;
                case 3 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:107:4: 'real'
                    {
                    match(input,22,FOLLOW_22_in_type210); 
                     result = RealType.instance; 

                    }
                    break;
                case 4 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:108:4: 'char'
                    {
                    match(input,23,FOLLOW_23_in_type220); 
                     result = CharType.instance; 

                    }
                    break;
                case 5 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:109:4: arrayType
                    {
                    pushFollow(FOLLOW_arrayType_in_type230);
                    arrayType5=arrayType();

                    state._fsp--;

                     result = arrayType5; 

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return result;
    }
    // $ANTLR end "type"


    // $ANTLR start "arrayType"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:112:1: arrayType returns [Type result] : 'array' '[' f= subrange ( ',' s= subrange )* ']' 'of' type ;
    public final Type arrayType() throws RecognitionException {
        Type result = null;

        PascalTo3addrParser.subrange_return f = null;

        PascalTo3addrParser.subrange_return s = null;

        Type type6 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:113:2: ( 'array' '[' f= subrange ( ',' s= subrange )* ']' 'of' type )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:113:4: 'array' '[' f= subrange ( ',' s= subrange )* ']' 'of' type
            {
            match(input,24,FOLLOW_24_in_arrayType250); 

            		List<Integer> lowers = new ArrayList<Integer>();
            		List<Integer> uppers = new ArrayList<Integer>();
            		List<Type> types = new ArrayList<Type>();
            	  
            match(input,25,FOLLOW_25_in_arrayType254); 
            pushFollow(FOLLOW_subrange_in_arrayType258);
            f=subrange();

            state._fsp--;


            	  	lowers.add((f!=null?f.lower:0));
            	  	uppers.add((f!=null?f.upper:0));
            	  	types.add((f!=null?f.type:null));
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:121:6: ( ',' s= subrange )*
            loop6:
            do {
                int alt6=2;
                int LA6_0 = input.LA(1);

                if ( (LA6_0==17) ) {
                    alt6=1;
                }


                switch (alt6) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:121:7: ',' s= subrange
            	    {
            	    match(input,17,FOLLOW_17_in_arrayType263); 
            	    pushFollow(FOLLOW_subrange_in_arrayType267);
            	    s=subrange();

            	    state._fsp--;


            	    	  	lowers.add((s!=null?s.lower:0));
            	    	  	uppers.add((s!=null?s.upper:0));
            	    	  	types.add((s!=null?s.type:null));
            	    	  

            	    }
            	    break;

            	default :
            	    break loop6;
                }
            } while (true);

            match(input,26,FOLLOW_26_in_arrayType274); 
            match(input,27,FOLLOW_27_in_arrayType276); 
            pushFollow(FOLLOW_type_in_arrayType278);
            type6=type();

            state._fsp--;


            	  	Type current = type6;
            	  	for (int i = 0; i < lowers.size(); ++i) {
            	  		current = new ArrayType(current, lowers.get(i), uppers.get(i), types.get(i));
            	  	}
            	  	result = current;
            	  

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return result;
    }
    // $ANTLR end "arrayType"

    public static class subrange_return extends ParserRuleReturnScope {
        public int lower;
        public int upper;
        public Type type;
    };

    // $ANTLR start "subrange"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:133:1: subrange returns [int lower, int upper, Type type] : l= enumConstant '..' u= enumConstant ;
    public final PascalTo3addrParser.subrange_return subrange() throws RecognitionException {
        PascalTo3addrParser.subrange_return retval = new PascalTo3addrParser.subrange_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.enumConstant_return l = null;

        PascalTo3addrParser.enumConstant_return u = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:134:2: (l= enumConstant '..' u= enumConstant )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:134:4: l= enumConstant '..' u= enumConstant
            {
            pushFollow(FOLLOW_enumConstant_in_subrange297);
            l=enumConstant();

            state._fsp--;

            match(input,28,FOLLOW_28_in_subrange299); 
            pushFollow(FOLLOW_enumConstant_in_subrange303);
            u=enumConstant();

            state._fsp--;


            		if (!(l!=null?l.type:null).equals((u!=null?u.type:null))) {
            			throw new CompilationError("Types of left and right bounds are not equal: " 
            			                           + (l!=null?l.type:null) + " for left and " + (u!=null?u.type:null) + " for right");
            		}
            		retval.lower = (l!=null?l.value:0);
            		retval.upper = (u!=null?u.value:0);
            		retval.type = (l!=null?l.type:null);
            	  

            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "subrange"

    public static class enumConstant_return extends ParserRuleReturnScope {
        public int value;
        public Type type;
    };

    // $ANTLR start "enumConstant"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:145:1: enumConstant returns [int value, Type type] : ( INT | CHAR | 'true' | 'false' );
    public final PascalTo3addrParser.enumConstant_return enumConstant() throws RecognitionException {
        PascalTo3addrParser.enumConstant_return retval = new PascalTo3addrParser.enumConstant_return();
        retval.start = input.LT(1);

        Token INT7=null;
        Token CHAR8=null;

        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:146:2: ( INT | CHAR | 'true' | 'false' )
            int alt7=4;
            switch ( input.LA(1) ) {
            case INT:
                {
                alt7=1;
                }
                break;
            case CHAR:
                {
                alt7=2;
                }
                break;
            case 29:
                {
                alt7=3;
                }
                break;
            case 30:
                {
                alt7=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 7, 0, input);

                throw nvae;
            }

            switch (alt7) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:146:4: INT
                    {
                    INT7=(Token)match(input,INT,FOLLOW_INT_in_enumConstant321); 
                     retval.value = Integer.parseInt((INT7!=null?INT7.getText():null)); retval.type = IntType.instance;     

                    }
                    break;
                case 2 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:147:4: CHAR
                    {
                    CHAR8=(Token)match(input,CHAR,FOLLOW_CHAR_in_enumConstant330); 
                     retval.value = (CHAR8!=null?CHAR8.getText():null).charAt(1);        retval.type = CharType.instance;    

                    }
                    break;
                case 3 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:148:4: 'true'
                    {
                    match(input,29,FOLLOW_29_in_enumConstant339); 
                     retval.value = 1;                           retval.type = BooleanType.instance; 

                    }
                    break;
                case 4 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:149:4: 'false'
                    {
                    match(input,30,FOLLOW_30_in_enumConstant349); 
                     retval.value = 0;                           retval.type = BooleanType.instance; 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "enumConstant"

    public static class constant_return extends ParserRuleReturnScope {
        public String text;
        public Type type;
    };

    // $ANTLR start "constant"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:152:1: constant returns [String text, Type type] : ( number | 'true' | 'false' );
    public final PascalTo3addrParser.constant_return constant() throws RecognitionException {
        PascalTo3addrParser.constant_return retval = new PascalTo3addrParser.constant_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.number_return number9 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:153:2: ( number | 'true' | 'false' )
            int alt8=3;
            switch ( input.LA(1) ) {
            case INT:
            case FLOAT:
                {
                alt8=1;
                }
                break;
            case 29:
                {
                alt8=2;
                }
                break;
            case 30:
                {
                alt8=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 8, 0, input);

                throw nvae;
            }

            switch (alt8) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:153:4: number
                    {
                    pushFollow(FOLLOW_number_in_constant368);
                    number9=number();

                    state._fsp--;

                    retval.text = (number9!=null?number9.text:null); retval.type = (number9!=null?number9.type:null);         

                    }
                    break;
                case 2 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:154:4: 'true'
                    {
                    match(input,29,FOLLOW_29_in_constant376); 
                    retval.text = "true";       retval.type = BooleanType.instance; 

                    }
                    break;
                case 3 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:155:4: 'false'
                    {
                    match(input,30,FOLLOW_30_in_constant385); 
                    retval.text = "false";      retval.type = BooleanType.instance; 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "constant"


    // $ANTLR start "statementSequence"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:157:1: statementSequence : 'begin' statement ( ';' statement )* 'end' ;
    public final void statementSequence() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:157:19: ( 'begin' statement ( ';' statement )* 'end' )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:157:21: 'begin' statement ( ';' statement )* 'end'
            {
            match(input,31,FOLLOW_31_in_statementSequence395); 
            pushFollow(FOLLOW_statement_in_statementSequence397);
            statement();

            state._fsp--;

            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:157:39: ( ';' statement )*
            loop9:
            do {
                int alt9=2;
                int LA9_0 = input.LA(1);

                if ( (LA9_0==15) ) {
                    alt9=1;
                }


                switch (alt9) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:157:40: ';' statement
            	    {
            	    match(input,15,FOLLOW_15_in_statementSequence400); 
            	    pushFollow(FOLLOW_statement_in_statementSequence402);
            	    statement();

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    break loop9;
                }
            } while (true);

            match(input,32,FOLLOW_32_in_statementSequence406); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "statementSequence"


    // $ANTLR start "statement"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:159:1: statement : ( ifStatement | whileStatement | repeatStatement | forStatement | iOStatement | statementSequence | | 'break' | 'continue' | assignment | functionCall );
    public final void statement() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:160:3: ( ifStatement | whileStatement | repeatStatement | forStatement | iOStatement | statementSequence | | 'break' | 'continue' | assignment | functionCall )
            int alt10=11;
            alt10 = dfa10.predict(input);
            switch (alt10) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:160:5: ifStatement
                    {
                    pushFollow(FOLLOW_ifStatement_in_statement418);
                    ifStatement();

                    state._fsp--;


                    }
                    break;
                case 2 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:161:5: whileStatement
                    {
                    pushFollow(FOLLOW_whileStatement_in_statement424);
                    whileStatement();

                    state._fsp--;


                    }
                    break;
                case 3 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:162:5: repeatStatement
                    {
                    pushFollow(FOLLOW_repeatStatement_in_statement431);
                    repeatStatement();

                    state._fsp--;


                    }
                    break;
                case 4 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:163:5: forStatement
                    {
                    pushFollow(FOLLOW_forStatement_in_statement437);
                    forStatement();

                    state._fsp--;


                    }
                    break;
                case 5 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:164:5: iOStatement
                    {
                    pushFollow(FOLLOW_iOStatement_in_statement443);
                    iOStatement();

                    state._fsp--;


                    }
                    break;
                case 6 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:165:5: statementSequence
                    {
                    pushFollow(FOLLOW_statementSequence_in_statement450);
                    statementSequence();

                    state._fsp--;


                    }
                    break;
                case 7 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:167:3: 
                    {
                    }
                    break;
                case 8 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:167:5: 'break'
                    {
                    match(input,33,FOLLOW_33_in_statement462); 
                     if (true) { throw new CompilationError("break is not implemented");    } 

                    }
                    break;
                case 9 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:168:5: 'continue'
                    {
                    match(input,34,FOLLOW_34_in_statement474); 
                     if (true) { throw new CompilationError("continue is not implemented"); } 

                    }
                    break;
                case 10 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:169:5: assignment
                    {
                    pushFollow(FOLLOW_assignment_in_statement483);
                    assignment();

                    state._fsp--;


                    }
                    break;
                case 11 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:170:5: functionCall
                    {
                    pushFollow(FOLLOW_functionCall_in_statement489);
                    functionCall();

                    state._fsp--;


                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "statement"


    // $ANTLR start "repeatStatement"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:173:1: repeatStatement : 'repeat' statement ( ';' statement )* 'until' expression ;
    public final void repeatStatement() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:173:17: ( 'repeat' statement ( ';' statement )* 'until' expression )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:173:19: 'repeat' statement ( ';' statement )* 'until' expression
            {
            match(input,35,FOLLOW_35_in_repeatStatement503); 
            pushFollow(FOLLOW_statement_in_repeatStatement506);
            statement();

            state._fsp--;

            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:173:39: ( ';' statement )*
            loop11:
            do {
                int alt11=2;
                int LA11_0 = input.LA(1);

                if ( (LA11_0==15) ) {
                    alt11=1;
                }


                switch (alt11) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:173:40: ';' statement
            	    {
            	    match(input,15,FOLLOW_15_in_repeatStatement509); 
            	    pushFollow(FOLLOW_statement_in_repeatStatement511);
            	    statement();

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    break loop11;
                }
            } while (true);

            match(input,36,FOLLOW_36_in_repeatStatement515); 
            pushFollow(FOLLOW_expression_in_repeatStatement518);
            expression();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "repeatStatement"


    // $ANTLR start "assignment"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:175:1: assignment : qualifiedName ':=' expression ;
    public final void assignment() throws RecognitionException {
        PascalTo3addrParser.qualifiedName_return qualifiedName10 = null;

        PascalTo3addrParser.expression_return expression11 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:176:2: ( qualifiedName ':=' expression )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:176:4: qualifiedName ':=' expression
            {
            pushFollow(FOLLOW_qualifiedName_in_assignment529);
            qualifiedName10=qualifiedName();

            state._fsp--;

            match(input,37,FOLLOW_37_in_assignment531); 
            pushFollow(FOLLOW_expression_in_assignment533);
            expression11=expression();

            state._fsp--;


            		if ((qualifiedName10!=null?qualifiedName10.type:null).equals((expression11!=null?expression11.type:null))) {
            			code.add((qualifiedName10!=null?qualifiedName10.access:null) + " = V" + (expression11!=null?expression11.variable:0));
            		} else if ((qualifiedName10!=null?qualifiedName10.type:null).equals(RealType.instance) && (expression11!=null?expression11.type:null).equals(IntType.instance)) {
            			int newVariable = allocateTempVariable(RealType.instance);
            			code.add("V" + newVariable + " = (" + RealType.instance + ") V" + (expression11!=null?expression11.variable:0));
            			code.add((qualifiedName10!=null?qualifiedName10.access:null) + " = V" + newVariable);
            		}
            	  

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "assignment"


    // $ANTLR start "ifStatement"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:187:1: ifStatement : 'if' expression 'then' statement ( 'else' statement )? ;
    public final void ifStatement() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:187:13: ( 'if' expression 'then' statement ( 'else' statement )? )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:187:15: 'if' expression 'then' statement ( 'else' statement )?
            {
            match(input,38,FOLLOW_38_in_ifStatement547); 
            pushFollow(FOLLOW_expression_in_ifStatement549);
            expression();

            state._fsp--;

            match(input,39,FOLLOW_39_in_ifStatement551); 
            pushFollow(FOLLOW_statement_in_ifStatement553);
            statement();

            state._fsp--;

            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:187:48: ( 'else' statement )?
            int alt12=2;
            int LA12_0 = input.LA(1);

            if ( (LA12_0==40) ) {
                alt12=1;
            }
            switch (alt12) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:187:49: 'else' statement
                    {
                    match(input,40,FOLLOW_40_in_ifStatement556); 
                    pushFollow(FOLLOW_statement_in_ifStatement558);
                    statement();

                    state._fsp--;


                    }
                    break;

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "ifStatement"


    // $ANTLR start "whileStatement"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:189:1: whileStatement : 'while' expression 'do' statement ;
    public final void whileStatement() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:189:16: ( 'while' expression 'do' statement )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:189:18: 'while' expression 'do' statement
            {
            match(input,41,FOLLOW_41_in_whileStatement569); 
            pushFollow(FOLLOW_expression_in_whileStatement571);
            expression();

            state._fsp--;

            match(input,42,FOLLOW_42_in_whileStatement573); 
            pushFollow(FOLLOW_statement_in_whileStatement575);
            statement();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "whileStatement"


    // $ANTLR start "forStatement"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:191:1: forStatement : 'for' ID ':=' forRange 'do' statement ;
    public final void forStatement() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:191:14: ( 'for' ID ':=' forRange 'do' statement )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:191:16: 'for' ID ':=' forRange 'do' statement
            {
            match(input,43,FOLLOW_43_in_forStatement584); 
            match(input,ID,FOLLOW_ID_in_forStatement586); 
            match(input,37,FOLLOW_37_in_forStatement588); 
            pushFollow(FOLLOW_forRange_in_forStatement590);
            forRange();

            state._fsp--;

            match(input,42,FOLLOW_42_in_forStatement592); 
            pushFollow(FOLLOW_statement_in_forStatement594);
            statement();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "forStatement"


    // $ANTLR start "forRange"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:192:1: forRange : expression whichWay expression ;
    public final void forRange() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:192:10: ( expression whichWay expression )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:192:12: expression whichWay expression
            {
            pushFollow(FOLLOW_expression_in_forRange602);
            expression();

            state._fsp--;

            pushFollow(FOLLOW_whichWay_in_forRange604);
            whichWay();

            state._fsp--;

            pushFollow(FOLLOW_expression_in_forRange606);
            expression();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "forRange"


    // $ANTLR start "whichWay"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:193:1: whichWay : ( 'to' | 'downto' );
    public final void whichWay() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:193:10: ( 'to' | 'downto' )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:
            {
            if ( (input.LA(1)>=44 && input.LA(1)<=45) ) {
                input.consume();
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "whichWay"


    // $ANTLR start "iOStatement"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:195:1: iOStatement : ( 'read' '(' qualifiedList ')' | 'readln' ( '(' qualifiedList ')' )? | 'write' '(' expList ')' | 'writeln' ( '(' expList ')' )? );
    public final void iOStatement() throws RecognitionException {
        PascalTo3addrParser.qualifiedList_return qualifiedList12 = null;

        PascalTo3addrParser.qualifiedList_return qualifiedList13 = null;

        PascalTo3addrParser.expList_return expList14 = null;

        PascalTo3addrParser.expList_return expList15 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:196:2: ( 'read' '(' qualifiedList ')' | 'readln' ( '(' qualifiedList ')' )? | 'write' '(' expList ')' | 'writeln' ( '(' expList ')' )? )
            int alt15=4;
            switch ( input.LA(1) ) {
            case 46:
                {
                alt15=1;
                }
                break;
            case 49:
                {
                alt15=2;
                }
                break;
            case 50:
                {
                alt15=3;
                }
                break;
            case 51:
                {
                alt15=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 15, 0, input);

                throw nvae;
            }

            switch (alt15) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:196:4: 'read' '(' qualifiedList ')'
                    {
                    match(input,46,FOLLOW_46_in_iOStatement628); 
                    match(input,47,FOLLOW_47_in_iOStatement630); 
                    pushFollow(FOLLOW_qualifiedList_in_iOStatement632);
                    qualifiedList12=qualifiedList();

                    state._fsp--;

                    match(input,48,FOLLOW_48_in_iOStatement634); 

                    		List<String> access = (qualifiedList12!=null?qualifiedList12.access:null);
                    		List<Type> types = (qualifiedList12!=null?qualifiedList12.types:null);
                    		for (int i = 0; i < types.size(); ++i) {
                    			int variable = allocateTempVariable(types.get(i));
                    			code.add("call read" + types.get(i) + " &V" + variable);
                    			code.add(access.get(i) + " = V" + variable);
                    		}
                    	  

                    }
                    break;
                case 2 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:205:4: 'readln' ( '(' qualifiedList ')' )?
                    {
                    match(input,49,FOLLOW_49_in_iOStatement642); 
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:205:13: ( '(' qualifiedList ')' )?
                    int alt13=2;
                    int LA13_0 = input.LA(1);

                    if ( (LA13_0==47) ) {
                        alt13=1;
                    }
                    switch (alt13) {
                        case 1 :
                            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:205:15: '(' qualifiedList ')'
                            {
                            match(input,47,FOLLOW_47_in_iOStatement646); 
                            pushFollow(FOLLOW_qualifiedList_in_iOStatement648);
                            qualifiedList13=qualifiedList();

                            state._fsp--;

                            match(input,48,FOLLOW_48_in_iOStatement650); 

                            		List<String> access = (qualifiedList13!=null?qualifiedList13.access:null);
                            		List<Type> types = (qualifiedList13!=null?qualifiedList13.types:null);
                            		for (int i = 0; i < types.size(); ++i) {
                            			int variable = allocateTempVariable(types.get(i));
                            			code.add("call read" + types.get(i) + " &V" + variable);
                            			code.add(access.get(i) + " = V" + variable);
                            		}
                            	  

                            }
                            break;

                    }


                    	  	code.add("call readLine");
                    	  

                    }
                    break;
                case 3 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:216:4: 'write' '(' expList ')'
                    {
                    match(input,50,FOLLOW_50_in_iOStatement663); 
                    match(input,47,FOLLOW_47_in_iOStatement665); 
                    pushFollow(FOLLOW_expList_in_iOStatement667);
                    expList14=expList();

                    state._fsp--;

                    match(input,48,FOLLOW_48_in_iOStatement669); 

                    		List<Integer> ids = (expList14!=null?expList14.ids:null);
                    		List<Type> types = (expList14!=null?expList14.types:null);
                    		for (int i = 0; i < ids.size(); ++i) {
                    			if (types.get(i) instanceof ArrayType) {
                    				throw new CompilationError("write(array) is not supported");
                    			} else {
                    				code.add("param V" + ids.get(i));
                    				code.add("call write" + types.get(i));
                    			}
                    		}
                    	  

                    }
                    break;
                case 4 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:228:4: 'writeln' ( '(' expList ')' )?
                    {
                    match(input,51,FOLLOW_51_in_iOStatement676); 
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:228:14: ( '(' expList ')' )?
                    int alt14=2;
                    int LA14_0 = input.LA(1);

                    if ( (LA14_0==47) ) {
                        alt14=1;
                    }
                    switch (alt14) {
                        case 1 :
                            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:228:16: '(' expList ')'
                            {
                            match(input,47,FOLLOW_47_in_iOStatement680); 
                            pushFollow(FOLLOW_expList_in_iOStatement682);
                            expList15=expList();

                            state._fsp--;

                            match(input,48,FOLLOW_48_in_iOStatement684); 

                            		List<Integer> ids = (expList15!=null?expList15.ids:null);
                            		List<Type> types = (expList15!=null?expList15.types:null);
                            		for (int i = 0; i < ids.size(); ++i) {
                            			if (types.get(i) instanceof ArrayType) {
                            				throw new CompilationError("write(array) is not supported");
                            			} else {
                            				code.add("param V" + ids.get(i));
                            				code.add("call write" + types.get(i));
                            			}
                            		}
                            	  

                            }
                            break;

                    }


                    	  	code.add("call writeLine");
                    	  

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "iOStatement"

    public static class actualParameters_return extends ParserRuleReturnScope {
        public List<Integer> ids;
        public List<Type> types;
    };

    // $ANTLR start "actualParameters"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:244:1: actualParameters returns [List<Integer> ids, List<Type> types] : '(' expList ')' ;
    public final PascalTo3addrParser.actualParameters_return actualParameters() throws RecognitionException {
        PascalTo3addrParser.actualParameters_return retval = new PascalTo3addrParser.actualParameters_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.expList_return expList16 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:245:2: ( '(' expList ')' )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:245:4: '(' expList ')'
            {
            match(input,47,FOLLOW_47_in_actualParameters707); 
            pushFollow(FOLLOW_expList_in_actualParameters709);
            expList16=expList();

            state._fsp--;

            match(input,48,FOLLOW_48_in_actualParameters711); 
             
            		retval.ids = (expList16!=null?expList16.ids:null); 
            		retval.types = (expList16!=null?expList16.types:null); 
            	  

            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "actualParameters"

    public static class expList_return extends ParserRuleReturnScope {
        public List<Integer> ids;
        public List<Type> types;
    };

    // $ANTLR start "expList"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:251:1: expList returns [List<Integer> ids, List<Type> types] : a= expression ( ',' b= expression )* ;
    public final PascalTo3addrParser.expList_return expList() throws RecognitionException {
        PascalTo3addrParser.expList_return retval = new PascalTo3addrParser.expList_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.expression_return a = null;

        PascalTo3addrParser.expression_return b = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:252:2: (a= expression ( ',' b= expression )* )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:252:4: a= expression ( ',' b= expression )*
            {
             
            		retval.ids = new ArrayList<Integer>(); 
            		retval.types = new ArrayList<Type>();
            	  
            pushFollow(FOLLOW_expression_in_expList733);
            a=expression();

            state._fsp--;

             
            	  	retval.ids.add((a!=null?a.variable:0)); 
            	  	retval.types.add((a!=null?a.type:null));
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:258:6: ( ',' b= expression )*
            loop16:
            do {
                int alt16=2;
                int LA16_0 = input.LA(1);

                if ( (LA16_0==17) ) {
                    alt16=1;
                }


                switch (alt16) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:258:8: ',' b= expression
            	    {
            	    match(input,17,FOLLOW_17_in_expList739); 
            	    pushFollow(FOLLOW_expression_in_expList743);
            	    b=expression();

            	    state._fsp--;

            	     
            	    	  	retval.ids.add((b!=null?b.variable:0));
            	    	  	retval.types.add((b!=null?b.type:null)); 
            	    	  

            	    }
            	    break;

            	default :
            	    break loop16;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "expList"

    public static class expression_return extends ParserRuleReturnScope {
        public int variable;
        public Type type;
    };

    // $ANTLR start "expression"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:263:1: expression returns [int variable, Type type] : a= simpleExpression ( relation b= simpleExpression )? ;
    public final PascalTo3addrParser.expression_return expression() throws RecognitionException {
        PascalTo3addrParser.expression_return retval = new PascalTo3addrParser.expression_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.simpleExpression_return a = null;

        PascalTo3addrParser.simpleExpression_return b = null;

        PascalTo3addrParser.relation_return relation17 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:264:2: (a= simpleExpression ( relation b= simpleExpression )? )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:264:4: a= simpleExpression ( relation b= simpleExpression )?
            {
            pushFollow(FOLLOW_simpleExpression_in_expression764);
            a=simpleExpression();

            state._fsp--;

             
            		retval.variable = (a!=null?a.variable:0);
            		retval.type = (a!=null?a.type:null);
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:267:6: ( relation b= simpleExpression )?
            int alt17=2;
            int LA17_0 = input.LA(1);

            if ( ((LA17_0>=61 && LA17_0<=66)) ) {
                alt17=1;
            }
            switch (alt17) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:267:8: relation b= simpleExpression
                    {
                    pushFollow(FOLLOW_relation_in_expression770);
                    relation17=relation();

                    state._fsp--;

                    pushFollow(FOLLOW_simpleExpression_in_expression774);
                    b=simpleExpression();

                    state._fsp--;


                    	  	if (retval.type.equals((b!=null?b.type:null))) {
                    	  		int newVariable = allocateTempVariable(BooleanType.instance);
                    	  		code.add("V" + newVariable + " = V" + retval.variable + " " + (relation17!=null?input.toString(relation17.start,relation17.stop):null) + " V" + (b!=null?b.variable:0));
                    	  		retval.variable = newVariable;
                    	  		retval.type = BooleanType.instance;
                    	  	} else {
                    	  		throw new CompilationError("Operation '" + (relation17!=null?input.toString(relation17.start,relation17.stop):null) + "' is not allowed for operands of type " + retval.type + " and " + (b!=null?b.type:null));
                    	  	}
                    	  

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "expression"

    public static class simpleExpression_return extends ParserRuleReturnScope {
        public int variable;
        public Type type;
    };

    // $ANTLR start "simpleExpression"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:278:1: simpleExpression returns [int variable, Type type] : ( unaryOperator )? a= term ( addOperator b= term )* ;
    public final PascalTo3addrParser.simpleExpression_return simpleExpression() throws RecognitionException {
        PascalTo3addrParser.simpleExpression_return retval = new PascalTo3addrParser.simpleExpression_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.term_return a = null;

        PascalTo3addrParser.term_return b = null;

        PascalTo3addrParser.unaryOperator_return unaryOperator18 = null;

        PascalTo3addrParser.addOperator_return addOperator19 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:279:2: ( ( unaryOperator )? a= term ( addOperator b= term )* )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:279:4: ( unaryOperator )? a= term ( addOperator b= term )*
            {

            		String unary = null; 
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:281:6: ( unaryOperator )?
            int alt18=2;
            int LA18_0 = input.LA(1);

            if ( ((LA18_0>=53 && LA18_0<=54)) ) {
                alt18=1;
            }
            switch (alt18) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:281:7: unaryOperator
                    {
                    pushFollow(FOLLOW_unaryOperator_in_simpleExpression796);
                    unaryOperator18=unaryOperator();

                    state._fsp--;


                    	    unary = (unaryOperator18!=null?input.toString(unaryOperator18.start,unaryOperator18.stop):null);
                    	  

                    }
                    break;

            }

            pushFollow(FOLLOW_term_in_simpleExpression805);
            a=term();

            state._fsp--;


              		retval.variable = (a!=null?a.variable:0);
              		retval.type = (a!=null?a.type:null);
            	  	if (unary != null) {
            	  		if (retval.type.isNumber()) {
            	  			int newVariable = allocateTempVariable(retval.type);
            	  			code.add("V" + newVariable + " = " + unary + " V" + retval.variable);
            	  			retval.variable = newVariable;
            	  		} else {
            	  			throw new CompilationError("Unary operator '" + unary + "' is not applicable to argument of type " + retval.type);
            	  		}
            	  	}
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:295:6: ( addOperator b= term )*
            loop19:
            do {
                int alt19=2;
                int LA19_0 = input.LA(1);

                if ( ((LA19_0>=53 && LA19_0<=54)||LA19_0==60) ) {
                    alt19=1;
                }


                switch (alt19) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:295:7: addOperator b= term
            	    {
            	    pushFollow(FOLLOW_addOperator_in_simpleExpression810);
            	    addOperator19=addOperator();

            	    state._fsp--;

            	    pushFollow(FOLLOW_term_in_simpleExpression814);
            	    b=term();

            	    state._fsp--;


            	    	  	String op = (addOperator19!=null?input.toString(addOperator19.start,addOperator19.stop):null);
            	    	  	if (op.equals("or")) {
            	    	  		if (retval.type.equals(BooleanType.instance) && (b!=null?b.type:null).equals(BooleanType.instance) ||
            	    	  		    retval.type.equals(IntType.instance) && (b!=null?b.type:null).equals(IntType.instance)) {
            	    	  			int newVariable = allocateTempVariable(retval.type);
            	    	  			code.add("V" + newVariable + " = V" + retval.variable + " " + op + " V" + (b!=null?b.variable:0));
            	    	  			retval.variable = newVariable;
            	    	  		} else {
            	    	  			throw new CompilationError("Binary operator 'or' is not applicable to arguments of type " + retval.type + " and " + (b!=null?b.type:null));
            	    	  		}
            	    	  	} else {
            	    	  		//+ or -
            	    	  		if (retval.type.isNumber() && (b!=null?b.type:null).isNumber()) {
            	    	  			int leftVariable, rightVariable;
            	    	  			Type maximumType;
            	    	  			if (retval.type.numberLevel() < (b!=null?b.type:null).numberLevel()) {
            	    	  				rightVariable = (b!=null?b.variable:0);
            	    	  				maximumType = (b!=null?b.type:null);
            	    	  				leftVariable = allocateTempVariable(maximumType);
            	    	  				code.add("V" + leftVariable + " = (" + maximumType + ") V" + retval.variable);
            	    	  			} else if (retval.type.numberLevel() > (b!=null?b.type:null).numberLevel()) {
            	    	  				leftVariable = retval.variable;
            	    	  				maximumType = retval.type;
            	    	  				rightVariable = allocateTempVariable(maximumType);
            	    	  				code.add("V" + rightVariable + " = (" + maximumType + ") V" + (b!=null?b.variable:0));
            	    	  			} else {
            	    	  				leftVariable = retval.variable;
            	    	  				rightVariable = (b!=null?b.variable:0);
            	    	  				maximumType = retval.type;
            	    	  			}
            	    	  			int newVariable = allocateTempVariable(maximumType);
            	    	  			code.add("V" + newVariable + " = V" + leftVariable + " " + op + " V" + rightVariable);
            	    	  			retval.variable = newVariable;
            	    	  			retval.type = maximumType;
            	    	  		} else {
            	    	  			throw new CompilationError("Binary operator '" + op + "' is not applicable to arguments of type " + retval.type + " and " + (b!=null?b.type:null));
            	    	  		}
            	    	  	}
            	    	  

            	    }
            	    break;

            	default :
            	    break loop19;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "simpleExpression"

    public static class term_return extends ParserRuleReturnScope {
        public int variable;
        public Type type;
    };

    // $ANTLR start "term"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:337:1: term returns [int variable, Type type] : a= factor ( multOperator b= factor )* ;
    public final PascalTo3addrParser.term_return term() throws RecognitionException {
        PascalTo3addrParser.term_return retval = new PascalTo3addrParser.term_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.factor_return a = null;

        PascalTo3addrParser.factor_return b = null;

        PascalTo3addrParser.multOperator_return multOperator20 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:338:2: (a= factor ( multOperator b= factor )* )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:338:4: a= factor ( multOperator b= factor )*
            {
            pushFollow(FOLLOW_factor_in_term835);
            a=factor();

            state._fsp--;


            		retval.variable = (a!=null?a.variable:0);
            		retval.type = (a!=null?a.type:null);
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:341:6: ( multOperator b= factor )*
            loop20:
            do {
                int alt20=2;
                int LA20_0 = input.LA(1);

                if ( ((LA20_0>=55 && LA20_0<=59)) ) {
                    alt20=1;
                }


                switch (alt20) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:341:7: multOperator b= factor
            	    {
            	    pushFollow(FOLLOW_multOperator_in_term840);
            	    multOperator20=multOperator();

            	    state._fsp--;

            	    pushFollow(FOLLOW_factor_in_term844);
            	    b=factor();

            	    state._fsp--;


            	    	  	String op = (multOperator20!=null?input.toString(multOperator20.start,multOperator20.stop):null);
            	    	  	if (op.equals("*")) {
            	    	  		if (retval.type.isNumber() && (b!=null?b.type:null).isNumber()) {
            	    	  			int leftVariable, rightVariable;
            	    	  			Type maximumType;
            	    	  			if (retval.type.numberLevel() < (b!=null?b.type:null).numberLevel()) {
            	    	  				rightVariable = (b!=null?b.variable:0);
            	    	  				maximumType = (b!=null?b.type:null);
            	    	  				leftVariable = allocateTempVariable(maximumType);
            	    	  				code.add("V" + leftVariable + " = (" + maximumType + ") V" + retval.variable);
            	    	  			} else if (retval.type.numberLevel() > (b!=null?b.type:null).numberLevel()) {
            	    	  				leftVariable = retval.variable;
            	    	  				maximumType = retval.type;
            	    	  				rightVariable = allocateTempVariable(maximumType);
            	    	  				code.add("V" + rightVariable + " = (" + maximumType + ") V" + (b!=null?b.variable:0));
            	    	  			} else {
            	    	  				leftVariable = retval.variable;
            	    	  				rightVariable = (b!=null?b.variable:0);
            	    	  				maximumType = retval.type;
            	    	  			}
            	    	  			int newVariable = allocateTempVariable(maximumType);
            	    	  			code.add("V" + newVariable + " = V" + leftVariable + " * V" + rightVariable);
            	    	  			retval.variable = newVariable;
            	    	  			retval.type = maximumType;
            	    	  		} else {
            	    	  			throw new CompilationError("Binary operator '*' is not applicable to arguments of type " + retval.type + " and " + (b!=null?b.type:null));
            	    	  		}
            	    	  	} else if (op.equals("/")) {
            	    	  		if (!retval.type.isNumber() && !a.type.isNumber()) {
            	    	  			throw new CompilationError("Binary operator '/' is not applicable to arguments of type " + retval.type + " and " + (b!=null?b.type:null));
            	    	  		}
            	    	  		int leftVariable, rightVariable;
            	    	  		if (retval.type.equals(RealType.instance)) {
            	    	  			leftVariable = retval.variable;
            	    	  		} else { 
            	    	  			leftVariable = allocateTempVariable(RealType.instance);
            	    	  			code.add("V" + leftVariable + " = (" + RealType.instance + ") V" + retval.variable);
            	    	  		}
            	    	  		if ((b!=null?b.type:null).equals(RealType.instance)) {
            	    	  			rightVariable = (b!=null?b.variable:0);
            	    	  		} else {
            	    	  			rightVariable = allocateTempVariable(RealType.instance);
            	    	  			code.add("V" + rightVariable + " = (" + RealType.instance + ") V" + (b!=null?b.variable:0));
            	    	  		}
            	    	  		retval.variable = allocateTempVariable(RealType.instance);
            	    	  		retval.type = RealType.instance;
            	    	  		code.add("V" + retval.variable + " = V" + leftVariable + " / V" + rightVariable);
            	    	  	} else if (op.equals("div") || op.equals("mod")) {
            	    	  		if (retval.type.equals(IntType.instance) && (b!=null?b.type:null).equals(IntType.instance)) {
            	    	  			int newVariable = allocateTempVariable(retval.type);
            	    	  			code.add("V" + newVariable + " = V" + retval.variable + " " + op + " V" + (b!=null?b.variable:0));
            	    	  			retval.variable = newVariable;
            	    	  		} else {
            	    	  			throw new CompilationError("Binary operator 'div' is not applicable to arguments of type " + retval.type + " and " + (b!=null?b.type:null));
            	    	  		}
            	    	  	} else if (op.equals("and")) {
            	    	  		if (retval.type.equals(IntType.instance) && (b!=null?b.type:null).equals(IntType.instance) ||
            	    	  		    retval.type.equals(BooleanType.instance) && (b!=null?b.type:null).equals(BooleanType.instance)) {
            	    	  			int newVariable = allocateTempVariable(retval.type);
            	    	  			code.add("V" + newVariable + " = V" + retval.variable + " " + op + " V" + (b!=null?b.variable:0));
            	    	  			retval.variable = newVariable;
            	    	  		} else {
            	    	  			throw new CompilationError("Binary operator 'div' is not applicable to arguments of type " + retval.type + " and " + (b!=null?b.type:null));
            	    	  		}
            	    	  	}
            	    	  

            	    }
            	    break;

            	default :
            	    break loop20;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "term"

    public static class factor_return extends ParserRuleReturnScope {
        public int variable;
        public Type type;
    };

    // $ANTLR start "factor"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:410:1: factor returns [int variable, Type type] : ( constant | ID ( actualParameters )+ | qualifiedName | '(' expression ')' | 'not' a= factor );
    public final PascalTo3addrParser.factor_return factor() throws RecognitionException {
        PascalTo3addrParser.factor_return retval = new PascalTo3addrParser.factor_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.factor_return a = null;

        PascalTo3addrParser.constant_return constant21 = null;

        PascalTo3addrParser.qualifiedName_return qualifiedName22 = null;

        PascalTo3addrParser.expression_return expression23 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:411:2: ( constant | ID ( actualParameters )+ | qualifiedName | '(' expression ')' | 'not' a= factor )
            int alt22=5;
            switch ( input.LA(1) ) {
            case INT:
            case FLOAT:
            case 29:
            case 30:
                {
                alt22=1;
                }
                break;
            case ID:
                {
                int LA22_2 = input.LA(2);

                if ( (LA22_2==47) ) {
                    alt22=2;
                }
                else if ( (LA22_2==15||LA22_2==17||(LA22_2>=25 && LA22_2<=26)||LA22_2==32||LA22_2==36||(LA22_2>=39 && LA22_2<=40)||LA22_2==42||(LA22_2>=44 && LA22_2<=45)||LA22_2==48||(LA22_2>=53 && LA22_2<=66)) ) {
                    alt22=3;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 22, 2, input);

                    throw nvae;
                }
                }
                break;
            case 47:
                {
                alt22=4;
                }
                break;
            case 52:
                {
                alt22=5;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 22, 0, input);

                throw nvae;
            }

            switch (alt22) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:411:4: constant
                    {
                    pushFollow(FOLLOW_constant_in_factor864);
                    constant21=constant();

                    state._fsp--;


                    		retval.type = (constant21!=null?constant21.type:null);
                    		retval.variable = allocateTempVariable(retval.type);
                    		code.add("V" + retval.variable + " = " + (constant21!=null?constant21.text:null));
                    	  

                    }
                    break;
                case 2 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:416:4: ID ( actualParameters )+
                    {
                    match(input,ID,FOLLOW_ID_in_factor874); 

                    		if (true) { throw new CompilationError("Functions are not supported yet"); }
                    	  
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:418:6: ( actualParameters )+
                    int cnt21=0;
                    loop21:
                    do {
                        int alt21=2;
                        int LA21_0 = input.LA(1);

                        if ( (LA21_0==47) ) {
                            alt21=1;
                        }


                        switch (alt21) {
                    	case 1 :
                    	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:418:7: actualParameters
                    	    {
                    	    pushFollow(FOLLOW_actualParameters_in_factor879);
                    	    actualParameters();

                    	    state._fsp--;


                    	    	  

                    	    }
                    	    break;

                    	default :
                    	    if ( cnt21 >= 1 ) break loop21;
                                EarlyExitException eee =
                                    new EarlyExitException(21, input);
                                throw eee;
                        }
                        cnt21++;
                    } while (true);


                    	  

                    }
                    break;
                case 3 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:421:4: qualifiedName
                    {
                    pushFollow(FOLLOW_qualifiedName_in_factor890);
                    qualifiedName22=qualifiedName();

                    state._fsp--;


                    		retval.type = (qualifiedName22!=null?qualifiedName22.type:null);
                    		retval.variable = allocateTempVariable(retval.type);
                    		code.add("V" + retval.variable + " = " + (qualifiedName22!=null?qualifiedName22.access:null)); 
                    	  

                    }
                    break;
                case 4 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:426:4: '(' expression ')'
                    {
                    match(input,47,FOLLOW_47_in_factor897); 
                    pushFollow(FOLLOW_expression_in_factor899);
                    expression23=expression();

                    state._fsp--;

                    match(input,48,FOLLOW_48_in_factor901); 
                     
                    		retval.variable = (expression23!=null?expression23.variable:0); retval.type = (expression23!=null?expression23.type:null); 
                    	  

                    }
                    break;
                case 5 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:429:4: 'not' a= factor
                    {
                    match(input,52,FOLLOW_52_in_factor909); 
                    pushFollow(FOLLOW_factor_in_factor913);
                    a=factor();

                    state._fsp--;


                    		if (!(a!=null?a.type:null).equals(BooleanType.instance) && !(a!=null?a.type:null).equals(IntType.instance)) {
                    			throw new CompilationError("Unary operator 'not' is not applicable to operand of type " + (a!=null?a.type:null));
                    		}
                    		retval.variable = allocateTempVariable((a!=null?a.type:null));
                    		retval.type = (a!=null?a.type:null);
                    		code.add("V" + retval.variable + " = not " + (a!=null?a.variable:0));
                    	  

                    }
                    break;

            }
            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "factor"

    public static class unaryOperator_return extends ParserRuleReturnScope {
    };

    // $ANTLR start "unaryOperator"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:439:1: unaryOperator : ( '+' | '-' ) ;
    public final PascalTo3addrParser.unaryOperator_return unaryOperator() throws RecognitionException {
        PascalTo3addrParser.unaryOperator_return retval = new PascalTo3addrParser.unaryOperator_return();
        retval.start = input.LT(1);

        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:439:15: ( ( '+' | '-' ) )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:439:17: ( '+' | '-' )
            {
            if ( (input.LA(1)>=53 && input.LA(1)<=54) ) {
                input.consume();
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "unaryOperator"

    public static class multOperator_return extends ParserRuleReturnScope {
    };

    // $ANTLR start "multOperator"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:441:1: multOperator : ( '*' | '/' | 'div' | 'mod' | 'and' ) ;
    public final PascalTo3addrParser.multOperator_return multOperator() throws RecognitionException {
        PascalTo3addrParser.multOperator_return retval = new PascalTo3addrParser.multOperator_return();
        retval.start = input.LT(1);

        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:441:15: ( ( '*' | '/' | 'div' | 'mod' | 'and' ) )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:441:17: ( '*' | '/' | 'div' | 'mod' | 'and' )
            {
            if ( (input.LA(1)>=55 && input.LA(1)<=59) ) {
                input.consume();
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "multOperator"

    public static class addOperator_return extends ParserRuleReturnScope {
    };

    // $ANTLR start "addOperator"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:443:1: addOperator : ( '+' | '-' | 'or' ) ;
    public final PascalTo3addrParser.addOperator_return addOperator() throws RecognitionException {
        PascalTo3addrParser.addOperator_return retval = new PascalTo3addrParser.addOperator_return();
        retval.start = input.LT(1);

        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:443:14: ( ( '+' | '-' | 'or' ) )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:443:16: ( '+' | '-' | 'or' )
            {
            if ( (input.LA(1)>=53 && input.LA(1)<=54)||input.LA(1)==60 ) {
                input.consume();
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "addOperator"

    public static class relation_return extends ParserRuleReturnScope {
    };

    // $ANTLR start "relation"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:445:1: relation : ( '=' | '<>' | '<' | '>' | '<=' | '>=' );
    public final PascalTo3addrParser.relation_return relation() throws RecognitionException {
        PascalTo3addrParser.relation_return retval = new PascalTo3addrParser.relation_return();
        retval.start = input.LT(1);

        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:445:10: ( '=' | '<>' | '<' | '>' | '<=' | '>=' )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:
            {
            if ( (input.LA(1)>=61 && input.LA(1)<=66) ) {
                input.consume();
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "relation"


    // $ANTLR start "functionCall"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:447:1: functionCall : ID ( actualParameters )? ;
    public final void functionCall() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:448:2: ( ID ( actualParameters )? )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:448:4: ID ( actualParameters )?
            {
            match(input,ID,FOLLOW_ID_in_functionCall1017); 

            		if (true) { throw new CompilationError("Functions are not supported yet"); }
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:450:5: ( actualParameters )?
            int alt23=2;
            int LA23_0 = input.LA(1);

            if ( (LA23_0==47) ) {
                alt23=1;
            }
            switch (alt23) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:450:6: actualParameters
                    {
                    pushFollow(FOLLOW_actualParameters_in_functionCall1021);
                    actualParameters();

                    state._fsp--;


                    }
                    break;

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "functionCall"


    // $ANTLR start "subprogDeclList"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:452:1: subprogDeclList : ( procedureDecl ';' | functionDecl ';' )* ;
    public final void subprogDeclList() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:452:17: ( ( procedureDecl ';' | functionDecl ';' )* )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:452:19: ( procedureDecl ';' | functionDecl ';' )*
            {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:452:19: ( procedureDecl ';' | functionDecl ';' )*
            loop24:
            do {
                int alt24=3;
                int LA24_0 = input.LA(1);

                if ( (LA24_0==67) ) {
                    alt24=1;
                }
                else if ( (LA24_0==68) ) {
                    alt24=2;
                }


                switch (alt24) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:452:20: procedureDecl ';'
            	    {
            	    pushFollow(FOLLOW_procedureDecl_in_subprogDeclList1033);
            	    procedureDecl();

            	    state._fsp--;

            	    match(input,15,FOLLOW_15_in_subprogDeclList1035); 

            	    }
            	    break;
            	case 2 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:452:40: functionDecl ';'
            	    {
            	    pushFollow(FOLLOW_functionDecl_in_subprogDeclList1039);
            	    functionDecl();

            	    state._fsp--;

            	    match(input,15,FOLLOW_15_in_subprogDeclList1041); 

            	    }
            	    break;

            	default :
            	    break loop24;
                }
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "subprogDeclList"


    // $ANTLR start "procedureDecl"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:454:1: procedureDecl : procedureHeading ';' block ;
    public final void procedureDecl() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:454:15: ( procedureHeading ';' block )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:454:17: procedureHeading ';' block
            {
            pushFollow(FOLLOW_procedureHeading_in_procedureDecl1053);
            procedureHeading();

            state._fsp--;

            match(input,15,FOLLOW_15_in_procedureDecl1055); 
            pushFollow(FOLLOW_block_in_procedureDecl1057);
            block();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "procedureDecl"


    // $ANTLR start "functionDecl"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:456:1: functionDecl : functionHeading ':' type ';' block ;
    public final void functionDecl() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:456:14: ( functionHeading ':' type ';' block )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:456:16: functionHeading ':' type ';' block
            {
            pushFollow(FOLLOW_functionHeading_in_functionDecl1066);
            functionHeading();

            state._fsp--;

            match(input,19,FOLLOW_19_in_functionDecl1068); 
            pushFollow(FOLLOW_type_in_functionDecl1070);
            type();

            state._fsp--;

            match(input,15,FOLLOW_15_in_functionDecl1072); 
            pushFollow(FOLLOW_block_in_functionDecl1074);
            block();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "functionDecl"


    // $ANTLR start "procedureHeading"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:458:1: procedureHeading : 'procedure' ID ( formalParameters )? ;
    public final void procedureHeading() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:458:18: ( 'procedure' ID ( formalParameters )? )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:458:20: 'procedure' ID ( formalParameters )?
            {
            match(input,67,FOLLOW_67_in_procedureHeading1083); 
            match(input,ID,FOLLOW_ID_in_procedureHeading1085); 
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:458:35: ( formalParameters )?
            int alt25=2;
            int LA25_0 = input.LA(1);

            if ( (LA25_0==47) ) {
                alt25=1;
            }
            switch (alt25) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:458:36: formalParameters
                    {
                    pushFollow(FOLLOW_formalParameters_in_procedureHeading1088);
                    formalParameters();

                    state._fsp--;


                    }
                    break;

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "procedureHeading"


    // $ANTLR start "functionHeading"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:460:1: functionHeading : 'function' ID ( formalParameters )? ;
    public final void functionHeading() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:460:17: ( 'function' ID ( formalParameters )? )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:460:19: 'function' ID ( formalParameters )?
            {
            match(input,68,FOLLOW_68_in_functionHeading1099); 
            match(input,ID,FOLLOW_ID_in_functionHeading1101); 
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:460:33: ( formalParameters )?
            int alt26=2;
            int LA26_0 = input.LA(1);

            if ( (LA26_0==47) ) {
                alt26=1;
            }
            switch (alt26) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:460:34: formalParameters
                    {
                    pushFollow(FOLLOW_formalParameters_in_functionHeading1104);
                    formalParameters();

                    state._fsp--;


                    }
                    break;

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "functionHeading"


    // $ANTLR start "formalParameters"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:462:1: formalParameters : '(' oneFormalParam ( ';' oneFormalParam )* ')' ;
    public final void formalParameters() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:462:18: ( '(' oneFormalParam ( ';' oneFormalParam )* ')' )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:462:20: '(' oneFormalParam ( ';' oneFormalParam )* ')'
            {
            match(input,47,FOLLOW_47_in_formalParameters1115); 
            pushFollow(FOLLOW_oneFormalParam_in_formalParameters1117);
            oneFormalParam();

            state._fsp--;

            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:462:39: ( ';' oneFormalParam )*
            loop27:
            do {
                int alt27=2;
                int LA27_0 = input.LA(1);

                if ( (LA27_0==15) ) {
                    alt27=1;
                }


                switch (alt27) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:462:40: ';' oneFormalParam
            	    {
            	    match(input,15,FOLLOW_15_in_formalParameters1120); 
            	    pushFollow(FOLLOW_oneFormalParam_in_formalParameters1122);
            	    oneFormalParam();

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    break loop27;
                }
            } while (true);

            match(input,48,FOLLOW_48_in_formalParameters1126); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "formalParameters"


    // $ANTLR start "oneFormalParam"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:464:1: oneFormalParam : ( 'var' )? idList ':' type ;
    public final void oneFormalParam() throws RecognitionException {
        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:464:16: ( ( 'var' )? idList ':' type )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:464:18: ( 'var' )? idList ':' type
            {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:464:18: ( 'var' )?
            int alt28=2;
            int LA28_0 = input.LA(1);

            if ( (LA28_0==18) ) {
                alt28=1;
            }
            switch (alt28) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:464:18: 'var'
                    {
                    match(input,18,FOLLOW_18_in_oneFormalParam1135); 

                    }
                    break;

            }

            pushFollow(FOLLOW_idList_in_oneFormalParam1138);
            idList();

            state._fsp--;

            match(input,19,FOLLOW_19_in_oneFormalParam1140); 
            pushFollow(FOLLOW_type_in_oneFormalParam1142);
            type();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "oneFormalParam"

    public static class qualifiedList_return extends ParserRuleReturnScope {
        public List<String> access;
        public List<Type> types;
    };

    // $ANTLR start "qualifiedList"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:466:1: qualifiedList returns [List<String> access, List<Type> types] : a= qualifiedName ( ',' b= qualifiedName )* ;
    public final PascalTo3addrParser.qualifiedList_return qualifiedList() throws RecognitionException {
        PascalTo3addrParser.qualifiedList_return retval = new PascalTo3addrParser.qualifiedList_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.qualifiedName_return a = null;

        PascalTo3addrParser.qualifiedName_return b = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:467:2: (a= qualifiedName ( ',' b= qualifiedName )* )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:467:4: a= qualifiedName ( ',' b= qualifiedName )*
            {

            		retval.access = new ArrayList<String>();
            		retval.types = new ArrayList<Type>();
            	  
            pushFollow(FOLLOW_qualifiedName_in_qualifiedList1160);
            a=qualifiedName();

            state._fsp--;


            	  	retval.access.add((a!=null?a.access:null));
            	  	retval.types.add((a!=null?a.type:null));
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:473:6: ( ',' b= qualifiedName )*
            loop29:
            do {
                int alt29=2;
                int LA29_0 = input.LA(1);

                if ( (LA29_0==17) ) {
                    alt29=1;
                }


                switch (alt29) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:473:7: ',' b= qualifiedName
            	    {
            	    match(input,17,FOLLOW_17_in_qualifiedList1165); 
            	    pushFollow(FOLLOW_qualifiedName_in_qualifiedList1169);
            	    b=qualifiedName();

            	    state._fsp--;


            	    	  	retval.access.add((b!=null?b.access:null));
            	    	  	retval.types.add((b!=null?b.type:null));
            	    	  

            	    }
            	    break;

            	default :
            	    break loop29;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "qualifiedList"

    public static class qualifiedName_return extends ParserRuleReturnScope {
        public String access;
        public Type type;
    };

    // $ANTLR start "qualifiedName"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:478:1: qualifiedName returns [String access, Type type] : ID ( qualifiedStuff )? ;
    public final PascalTo3addrParser.qualifiedName_return qualifiedName() throws RecognitionException {
        PascalTo3addrParser.qualifiedName_return retval = new PascalTo3addrParser.qualifiedName_return();
        retval.start = input.LT(1);

        Token ID24=null;
        PascalTo3addrParser.qualifiedStuff_return qualifiedStuff25 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:479:2: ( ID ( qualifiedStuff )? )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:479:4: ID ( qualifiedStuff )?
            {
            ID24=(Token)match(input,ID,FOLLOW_ID_in_qualifiedName1187); 

            		int id = resolveID((ID24!=null?ID24.getText():null));
            		retval.type = resolveType((ID24!=null?ID24.getText():null));
            		retval.access = "V" + id;
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:483:6: ( qualifiedStuff )?
            int alt30=2;
            int LA30_0 = input.LA(1);

            if ( (LA30_0==25) ) {
                alt30=1;
            }
            switch (alt30) {
                case 1 :
                    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:483:7: qualifiedStuff
                    {
                    pushFollow(FOLLOW_qualifiedStuff_in_qualifiedName1192);
                    qualifiedStuff25=qualifiedStuff();

                    state._fsp--;


                    	  	List<Integer> ids = (qualifiedStuff25!=null?qualifiedStuff25.ids:null);
                    	  	List<Type> types = (qualifiedStuff25!=null?qualifiedStuff25.types:null);
                    	  	int indexVariable = -1;
                    	  	for (int i = 0; i < ids.size(); ++i) {
                    	  		if (retval.type instanceof ArrayType) {
                    	  			ArrayType arr = (ArrayType) (retval.type);
                    	  			if (arr.indexType.equals(types.get(i))) {
                    	  				int tmpVariable = allocateTempVariable(IntType.instance);
                    	  				if (types.get(i).equals(IntType.instance)) {
                    	  					if (arr.lowerBound == 0) {
                    	  						code.add("V" + tmpVariable + " = V" + ids.get(i));
                    	  					} else {
                    	  						code.add("V" + tmpVariable + " = V" + ids.get(i) + " - " + arr.lowerBound);
                    	  					}
                    	  				} else {
                    	  					code.add("V" + tmpVariable + " = (" + IntType.instance + ") V" + ids.get(i));
                    	  					if (arr.lowerBound != 0) {
                    	  						code.add("V" + tmpVariable + " = V" + tmpVariable + " - " + arr.lowerBound);
                    	  					}
                    	  				}
                    	  				if (indexVariable != -1) {
                    	  					code.add("V" + indexVariable + " = V" + indexVariable + " * " + (arr.upperBound - arr.lowerBound + 1));
                    	  					code.add("V" + indexVariable + " = V" + indexVariable + " + V" + tmpVariable);
                    					} else {
                    						indexVariable = tmpVariable;
                    					}
                    					retval.type = arr.baseType;
                    	  			} else {
                    		  			throw new CompilationError("Index type mismatch at depth " + (i + 1) + 
                    		  									   ": expected " + arr.indexType + ", found " + types.get(i));
                    	  			}
                    	  		} else {
                    	  			throw new CompilationError("Expected array of depth " + ids.size() + ", found " + resolveType((ID24!=null?ID24.getText():null)));
                    	  		}
                    	  	}
                    	  	if (retval.type instanceof ArrayType) {
                    			throw new CompilationError("Too few indices (" + ids.size() + ") for variable of type " + resolveType((ID24!=null?ID24.getText():null)));
                    	  	}
                    	  	//Change here if you want the pointer notation to be generated.
                    	  	retval.access = "V" + id + "[V" + indexVariable + "]";
                    	  

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "qualifiedName"

    public static class qualifiedStuff_return extends ParserRuleReturnScope {
        public List<Integer> ids;
        public List<Type> types;
    };

    // $ANTLR start "qualifiedStuff"
    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:527:1: qualifiedStuff returns [List<Integer> ids, List<Type> types] : ( '[' expList ']' )+ ;
    public final PascalTo3addrParser.qualifiedStuff_return qualifiedStuff() throws RecognitionException {
        PascalTo3addrParser.qualifiedStuff_return retval = new PascalTo3addrParser.qualifiedStuff_return();
        retval.start = input.LT(1);

        PascalTo3addrParser.expList_return expList26 = null;


        try {
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:528:2: ( ( '[' expList ']' )+ )
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:528:4: ( '[' expList ']' )+
            {

            		retval.ids = new ArrayList<Integer>();
            		retval.types = new ArrayList<Type>();
            	  
            // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:531:6: ( '[' expList ']' )+
            int cnt31=0;
            loop31:
            do {
                int alt31=2;
                int LA31_0 = input.LA(1);

                if ( (LA31_0==25) ) {
                    alt31=1;
                }


                switch (alt31) {
            	case 1 :
            	    // C:\\Users\\Arina\\Documents\\ITMO\\[homeworks]\\5course\\PascalCompiler\\PascalCompiler\\src\\PascalTo3addr.g:531:7: '[' expList ']'
            	    {
            	    match(input,25,FOLLOW_25_in_qualifiedStuff1215); 
            	    pushFollow(FOLLOW_expList_in_qualifiedStuff1217);
            	    expList26=expList();

            	    state._fsp--;

            	     
            	    	  	retval.ids.addAll((expList26!=null?expList26.ids:null)); 
            	    	  	retval.types.addAll((expList26!=null?expList26.types:null));
            	    	  
            	    match(input,26,FOLLOW_26_in_qualifiedStuff1221); 

            	    }
            	    break;

            	default :
            	    if ( cnt31 >= 1 ) break loop31;
                        EarlyExitException eee =
                            new EarlyExitException(31, input);
                        throw eee;
                }
                cnt31++;
            } while (true);


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "qualifiedStuff"

    // Delegated rules


    protected DFA10 dfa10 = new DFA10(this);
    static final String DFA10_eotS =
        "\15\uffff";
    static final String DFA10_eofS =
        "\15\uffff";
    static final String DFA10_minS =
        "\1\4\11\uffff\1\17\2\uffff";
    static final String DFA10_maxS =
        "\1\63\11\uffff\1\57\2\uffff";
    static final String DFA10_acceptS =
        "\1\uffff\1\1\1\2\1\3\1\4\1\5\1\6\1\7\1\10\1\11\1\uffff\1\12\1\13";
    static final String DFA10_specialS =
        "\15\uffff}>";
    static final String[] DFA10_transitionS = {
            "\1\12\12\uffff\1\7\17\uffff\1\6\1\7\1\10\1\11\1\3\1\7\1\uffff"+
            "\1\1\1\uffff\1\7\1\2\1\uffff\1\4\2\uffff\1\5\2\uffff\3\5",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "\1\14\11\uffff\1\13\6\uffff\1\14\3\uffff\1\14\1\13\2\uffff"+
            "\1\14\6\uffff\1\14",
            "",
            ""
    };

    static final short[] DFA10_eot = DFA.unpackEncodedString(DFA10_eotS);
    static final short[] DFA10_eof = DFA.unpackEncodedString(DFA10_eofS);
    static final char[] DFA10_min = DFA.unpackEncodedStringToUnsignedChars(DFA10_minS);
    static final char[] DFA10_max = DFA.unpackEncodedStringToUnsignedChars(DFA10_maxS);
    static final short[] DFA10_accept = DFA.unpackEncodedString(DFA10_acceptS);
    static final short[] DFA10_special = DFA.unpackEncodedString(DFA10_specialS);
    static final short[][] DFA10_transition;

    static {
        int numStates = DFA10_transitionS.length;
        DFA10_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA10_transition[i] = DFA.unpackEncodedString(DFA10_transitionS[i]);
        }
    }

    class DFA10 extends DFA {

        public DFA10(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 10;
            this.eot = DFA10_eot;
            this.eof = DFA10_eof;
            this.min = DFA10_min;
            this.max = DFA10_max;
            this.accept = DFA10_accept;
            this.special = DFA10_special;
            this.transition = DFA10_transition;
        }
        public String getDescription() {
            return "159:1: statement : ( ifStatement | whileStatement | repeatStatement | forStatement | iOStatement | statementSequence | | 'break' | 'continue' | assignment | functionCall );";
        }
    }
 

    public static final BitSet FOLLOW_module_in_parse28 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_14_in_module39 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_module41 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_module43 = new BitSet(new long[]{0x0000000000040000L,0x0000000000000018L});
    public static final BitSet FOLLOW_block_in_module45 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_16_in_module47 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_INT_in_number62 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FLOAT_in_number72 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_idList93 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_17_in_idList98 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_idList102 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_declarations_in_block124 = new BitSet(new long[]{0x0000000080000000L});
    public static final BitSet FOLLOW_statementSequence_in_block126 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_variableDeclBlock_in_declarations140 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000018L});
    public static final BitSet FOLLOW_subprogDeclList_in_declarations144 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_18_in_variableDeclBlock153 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_variableDecl_in_variableDeclBlock155 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_variableDeclBlock157 = new BitSet(new long[]{0x0000000000000012L});
    public static final BitSet FOLLOW_variableDecl_in_variableDeclBlock160 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_variableDeclBlock162 = new BitSet(new long[]{0x0000000000000012L});
    public static final BitSet FOLLOW_idList_in_variableDecl175 = new BitSet(new long[]{0x0000000000080000L});
    public static final BitSet FOLLOW_19_in_variableDecl177 = new BitSet(new long[]{0x0000000001F00000L});
    public static final BitSet FOLLOW_type_in_variableDecl179 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_20_in_type196 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_21_in_type203 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_22_in_type210 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_23_in_type220 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_arrayType_in_type230 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_24_in_arrayType250 = new BitSet(new long[]{0x0000000002000000L});
    public static final BitSet FOLLOW_25_in_arrayType254 = new BitSet(new long[]{0x00000000600000A0L});
    public static final BitSet FOLLOW_subrange_in_arrayType258 = new BitSet(new long[]{0x0000000004020000L});
    public static final BitSet FOLLOW_17_in_arrayType263 = new BitSet(new long[]{0x00000000600000A0L});
    public static final BitSet FOLLOW_subrange_in_arrayType267 = new BitSet(new long[]{0x0000000004020000L});
    public static final BitSet FOLLOW_26_in_arrayType274 = new BitSet(new long[]{0x0000000008000000L});
    public static final BitSet FOLLOW_27_in_arrayType276 = new BitSet(new long[]{0x0000000001F00000L});
    public static final BitSet FOLLOW_type_in_arrayType278 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_enumConstant_in_subrange297 = new BitSet(new long[]{0x0000000010000000L});
    public static final BitSet FOLLOW_28_in_subrange299 = new BitSet(new long[]{0x00000000600000A0L});
    public static final BitSet FOLLOW_enumConstant_in_subrange303 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_INT_in_enumConstant321 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CHAR_in_enumConstant330 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_29_in_enumConstant339 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_30_in_enumConstant349 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_number_in_constant368 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_29_in_constant376 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_30_in_constant385 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_31_in_statementSequence395 = new BitSet(new long[]{0x000E4A4F80008010L});
    public static final BitSet FOLLOW_statement_in_statementSequence397 = new BitSet(new long[]{0x0000000100008000L});
    public static final BitSet FOLLOW_15_in_statementSequence400 = new BitSet(new long[]{0x000E4A4F80008010L});
    public static final BitSet FOLLOW_statement_in_statementSequence402 = new BitSet(new long[]{0x0000000100008000L});
    public static final BitSet FOLLOW_32_in_statementSequence406 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ifStatement_in_statement418 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_whileStatement_in_statement424 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_repeatStatement_in_statement431 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_forStatement_in_statement437 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_iOStatement_in_statement443 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_statementSequence_in_statement450 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_33_in_statement462 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_34_in_statement474 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_assignment_in_statement483 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_functionCall_in_statement489 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_35_in_repeatStatement503 = new BitSet(new long[]{0x000E4A5E80008010L});
    public static final BitSet FOLLOW_statement_in_repeatStatement506 = new BitSet(new long[]{0x0000001000008000L});
    public static final BitSet FOLLOW_15_in_repeatStatement509 = new BitSet(new long[]{0x000E4A5E80008010L});
    public static final BitSet FOLLOW_statement_in_repeatStatement511 = new BitSet(new long[]{0x0000001000008000L});
    public static final BitSet FOLLOW_36_in_repeatStatement515 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expression_in_repeatStatement518 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_qualifiedName_in_assignment529 = new BitSet(new long[]{0x0000002000000000L});
    public static final BitSet FOLLOW_37_in_assignment531 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expression_in_assignment533 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_38_in_ifStatement547 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expression_in_ifStatement549 = new BitSet(new long[]{0x0000008000000000L});
    public static final BitSet FOLLOW_39_in_ifStatement551 = new BitSet(new long[]{0x000E4B4E80000010L});
    public static final BitSet FOLLOW_statement_in_ifStatement553 = new BitSet(new long[]{0x0000010000000002L});
    public static final BitSet FOLLOW_40_in_ifStatement556 = new BitSet(new long[]{0x000E4A4E80000010L});
    public static final BitSet FOLLOW_statement_in_ifStatement558 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_41_in_whileStatement569 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expression_in_whileStatement571 = new BitSet(new long[]{0x0000040000000000L});
    public static final BitSet FOLLOW_42_in_whileStatement573 = new BitSet(new long[]{0x000E4A4E80000010L});
    public static final BitSet FOLLOW_statement_in_whileStatement575 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_43_in_forStatement584 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_forStatement586 = new BitSet(new long[]{0x0000002000000000L});
    public static final BitSet FOLLOW_37_in_forStatement588 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_forRange_in_forStatement590 = new BitSet(new long[]{0x0000040000000000L});
    public static final BitSet FOLLOW_42_in_forStatement592 = new BitSet(new long[]{0x000E4A4E80000010L});
    public static final BitSet FOLLOW_statement_in_forStatement594 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expression_in_forRange602 = new BitSet(new long[]{0x0000300000000000L});
    public static final BitSet FOLLOW_whichWay_in_forRange604 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expression_in_forRange606 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_whichWay0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_46_in_iOStatement628 = new BitSet(new long[]{0x0000800000000000L});
    public static final BitSet FOLLOW_47_in_iOStatement630 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_qualifiedList_in_iOStatement632 = new BitSet(new long[]{0x0001000000000000L});
    public static final BitSet FOLLOW_48_in_iOStatement634 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_49_in_iOStatement642 = new BitSet(new long[]{0x0000800000000002L});
    public static final BitSet FOLLOW_47_in_iOStatement646 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_qualifiedList_in_iOStatement648 = new BitSet(new long[]{0x0001000000000000L});
    public static final BitSet FOLLOW_48_in_iOStatement650 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_50_in_iOStatement663 = new BitSet(new long[]{0x0000800000000000L});
    public static final BitSet FOLLOW_47_in_iOStatement665 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expList_in_iOStatement667 = new BitSet(new long[]{0x0001000000000000L});
    public static final BitSet FOLLOW_48_in_iOStatement669 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_51_in_iOStatement676 = new BitSet(new long[]{0x0000800000000002L});
    public static final BitSet FOLLOW_47_in_iOStatement680 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expList_in_iOStatement682 = new BitSet(new long[]{0x0001000000000000L});
    public static final BitSet FOLLOW_48_in_iOStatement684 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_47_in_actualParameters707 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expList_in_actualParameters709 = new BitSet(new long[]{0x0001000000000000L});
    public static final BitSet FOLLOW_48_in_actualParameters711 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expression_in_expList733 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_17_in_expList739 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expression_in_expList743 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_simpleExpression_in_expression764 = new BitSet(new long[]{0xE000000000000002L,0x0000000000000007L});
    public static final BitSet FOLLOW_relation_in_expression770 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_simpleExpression_in_expression774 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_unaryOperator_in_simpleExpression796 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_term_in_simpleExpression805 = new BitSet(new long[]{0x1060000000000002L});
    public static final BitSet FOLLOW_addOperator_in_simpleExpression810 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_term_in_simpleExpression814 = new BitSet(new long[]{0x1060000000000002L});
    public static final BitSet FOLLOW_factor_in_term835 = new BitSet(new long[]{0x0F80000000000002L});
    public static final BitSet FOLLOW_multOperator_in_term840 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_factor_in_term844 = new BitSet(new long[]{0x0F80000000000002L});
    public static final BitSet FOLLOW_constant_in_factor864 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_factor874 = new BitSet(new long[]{0x0000800000000000L});
    public static final BitSet FOLLOW_actualParameters_in_factor879 = new BitSet(new long[]{0x0000800000000002L});
    public static final BitSet FOLLOW_qualifiedName_in_factor890 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_47_in_factor897 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expression_in_factor899 = new BitSet(new long[]{0x0001000000000000L});
    public static final BitSet FOLLOW_48_in_factor901 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_52_in_factor909 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_factor_in_factor913 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_unaryOperator925 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_multOperator941 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_addOperator968 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_relation0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_functionCall1017 = new BitSet(new long[]{0x0000800000000002L});
    public static final BitSet FOLLOW_actualParameters_in_functionCall1021 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_procedureDecl_in_subprogDeclList1033 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_subprogDeclList1035 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000018L});
    public static final BitSet FOLLOW_functionDecl_in_subprogDeclList1039 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_subprogDeclList1041 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000018L});
    public static final BitSet FOLLOW_procedureHeading_in_procedureDecl1053 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_procedureDecl1055 = new BitSet(new long[]{0x0000000000040000L,0x0000000000000018L});
    public static final BitSet FOLLOW_block_in_procedureDecl1057 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_functionHeading_in_functionDecl1066 = new BitSet(new long[]{0x0000000000080000L});
    public static final BitSet FOLLOW_19_in_functionDecl1068 = new BitSet(new long[]{0x0000000001F00000L});
    public static final BitSet FOLLOW_type_in_functionDecl1070 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_functionDecl1072 = new BitSet(new long[]{0x0000000000040000L,0x0000000000000018L});
    public static final BitSet FOLLOW_block_in_functionDecl1074 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_67_in_procedureHeading1083 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_procedureHeading1085 = new BitSet(new long[]{0x0000800000000002L});
    public static final BitSet FOLLOW_formalParameters_in_procedureHeading1088 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_68_in_functionHeading1099 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_ID_in_functionHeading1101 = new BitSet(new long[]{0x0000800000000002L});
    public static final BitSet FOLLOW_formalParameters_in_functionHeading1104 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_47_in_formalParameters1115 = new BitSet(new long[]{0x0000000000040010L});
    public static final BitSet FOLLOW_oneFormalParam_in_formalParameters1117 = new BitSet(new long[]{0x0001000000008000L});
    public static final BitSet FOLLOW_15_in_formalParameters1120 = new BitSet(new long[]{0x0000000000040010L});
    public static final BitSet FOLLOW_oneFormalParam_in_formalParameters1122 = new BitSet(new long[]{0x0001000000008000L});
    public static final BitSet FOLLOW_48_in_formalParameters1126 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_18_in_oneFormalParam1135 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_idList_in_oneFormalParam1138 = new BitSet(new long[]{0x0000000000080000L});
    public static final BitSet FOLLOW_19_in_oneFormalParam1140 = new BitSet(new long[]{0x0000000001F00000L});
    public static final BitSet FOLLOW_type_in_oneFormalParam1142 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_qualifiedName_in_qualifiedList1160 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_17_in_qualifiedList1165 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_qualifiedName_in_qualifiedList1169 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_ID_in_qualifiedName1187 = new BitSet(new long[]{0x0000000002000002L});
    public static final BitSet FOLLOW_qualifiedStuff_in_qualifiedName1192 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_25_in_qualifiedStuff1215 = new BitSet(new long[]{0x0070800060000070L});
    public static final BitSet FOLLOW_expList_in_qualifiedStuff1217 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_26_in_qualifiedStuff1221 = new BitSet(new long[]{0x0000000002000002L});

}